package com.py.credit.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import com.py.credit.dao.CreditServerDao;
import com.py.credit.entity.CallAchievementsLog;
import com.py.credit.entity.CallInterfaceInfo;
import com.py.credit.entity.ReturnResultJson;
import com.py.credit.service.CreditServerService;
import com.py.credit.utils.SQLBuilder;
import com.py.framework.core.common.Page;
import com.py.framework.core.exception.ServiceException;

@Service
public class CreditServerServiceImpl implements CreditServerService {

	@Autowired
	private CreditServerDao creditServerDao;

	@Override
	public Map<String, Object> getModelByOffice(String serviceCode, Long deptId , String ztType) {
		return creditServerDao.getModelByOffice(serviceCode, deptId , ztType);
	}


	@Override
	public ReturnResultJson getMap(String modelId,String ztName ,String ztDm) {
		return creditServerDao.getMap(modelId , ztName , ztDm);
	}


	@Override
	public ReturnResultJson getMapOth(String ztName ,String ztDm) {
		return creditServerDao.getMapOth(ztName , ztDm);
	}


	@Override
	public void insertCallInfo(CallInterfaceInfo callInfo) {
		creditServerDao.insertCallInfo(callInfo);
	}


	@Override
	public int insertFeedbackInfo(String callbackUsage, String checkcode) {
		return creditServerDao.insertFeedbackInfo(callbackUsage, checkcode);
	}


	@Override
	public List<Map<String, Object>> getAchievements(String ywId,String ztType ,Long deptId, List<String> showColumns, String[] additionalColumns,
			String condition, Page page) {
		
		if (CollectionUtils.isEmpty(showColumns)) {
            throw new ServiceException("至少选择一列");
        }
        List<String> conditions = SQLBuilder.createConditionSql(condition);
        
        List<Map<String, Object>> list = creditServerDao.getAchievementsByConditionForPage(ywId , ztType , deptId ,showColumns,additionalColumns, conditions, page);
		return list;
	}


	@Override
	public int insertCallInfos(List<CallInterfaceInfo> callInfos) {
		return creditServerDao.insertCallInfos(callInfos);
	}


	@Override
	public void insertCallLog(CallAchievementsLog callLog) {
		creditServerDao.insertCallLog(callLog);
	}

	
	
	

}
